<template>
  <div class="shareItem">
    <h3 class="title van-ellipsis" v-html="info.title" @click="goInfo"></h3>
    <div class="txt van-multi-ellipsis--l2" @click="goInfo">
      {{ info.content }}
    </div>
    <div class="other">
      <img
        v-if="info.author.avatar"
        :src="$baseUrl + info.author.avatar"
        alt=""
        class="o1"
      />
      <img v-else src="@/assets/logo.png" alt="" class="o1" />
      <div class="o2">{{ info.author.nickname }}</div>
      <div class="o3">{{ info.updated_at | formatTime }}</div>
      <div class="o4 iconfont">&#xe65b;</div>
      <div class="o5">{{ info.read }}</div>
      <div
        class="o4 iconfont"
        :class="{ red: isLogin && userInfo.starArticles.includes(info.id) }"
      >
        &#xe638;
      </div>
      <div
        class="o5"
        :class="{ red: isLogin && userInfo.starArticles.includes(info.id) }"
      >
        {{ info.star }}
      </div>
    </div>
  </div>
</template>
<script>
import { mapState } from 'vuex'
export default {
  props: ['info'],
  computed: {
    ...mapState(['userInfo', 'isLogin'])
  },
  methods: {
    goInfo () {
      this.$router.push(
        '/home/shareInfo/' + this.info.id + '?repath=' + this.$route.fullPath
      )
      //
      // 1:配制路由  /home/shareInfo/:id  2:传  this.$router.push('/home/shareInfo/值')
      // 3:this.$route.params.id
    }
  }
}
</script>
<style lang="less" scoped>
.shareItem {
  .title {
    font-size: 16px;
    font-family: PingFangSC, PingFangSC-Medium;
    font-weight: 500;
    text-align: left;
    color: #181a39;
    line-height: 22px;
    letter-spacing: 0px;
  }
  .txt {
    margin: 10px 0;
    font-size: 13px;
    font-family: PingFangSC, PingFangSC-Regular;
    font-weight: 400;
    text-align: left;
    color: #545671;
    line-height: 18px;
    letter-spacing: 0px;
  }
  .other {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: #ccc;
    .o1 {
      width: 22px;
      height: 22px;
      opacity: 1;
      border-radius: 50%;
    }
    .o2 {
      flex: 1;
    }
  }
  .red {
    color: red !important;
  }
}
</style>
